﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using RZD_maps.Modules.Ribbon.Common;
using System.ComponentModel;
using System.Collections.ObjectModel;
using RZD_maps.Modules.Ribbon.ViewModel;

//using RZD_maps.MapPath;

namespace RZD_maps.Modules.Ribbon.Model
{
    public static class rzd_model
    {

        public static RibbonViewModel ViewModel = null;

        #region Application Menu
        public static ControlData New
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "_New";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(DefaultExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Bing
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Bing";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(BingExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData OpenStreetMap
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "OpenStreet Map";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(OSMExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Plain
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Plain";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(PlainExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData MapProvider
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Источник";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            //Command = new DelegateCommand(DefaultExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Vehicle
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Транспорт";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(VehicleExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Stations
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Станции";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(StationExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Road
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Пути";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(LineExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Markers
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Маркеры";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(MarkersExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Scale100
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Масштаб: 100";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(Scale100Executed, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Scale10
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Масштаб: 10";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(Scale10Executed, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData LookMap
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Вид карты";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        string TooTipTitle = "Выбор вида карты";
                        string ToolTipDescription = "Выбрать вид карты";
                        string DropDownToolTipDescription = "Нажмите здесь, чтобы выбрать вид карты.";

                        SplitButtonData splitButtonData = new SplitButtonData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RibbonWindowSample;component/Images/Paste_16x16.png", UriKind.Relative),
                            //LargeImage = new Uri("/RibbonWindowSample;component/Images/Paste_32x32.png", UriKind.Relative),
                            ToolTipTitle = TooTipTitle,
                            ToolTipDescription = ToolTipDescription,
                            Command = ApplicationCommands.Paste
                        };
                        splitButtonData.DropDownButtonData.ToolTipTitle = TooTipTitle;
                        splitButtonData.DropDownButtonData.ToolTipDescription = DropDownToolTipDescription;
                        splitButtonData.DropDownButtonData.Command = new DelegateCommand(DefaultExecuted, DefaultCanExecute);
                        _dataCollection[Str] = splitButtonData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData LookRoad
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Road";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(LookRoadExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData LookHybrid
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Hybrid";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(LookHybridExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Graphic1
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "График 1";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(Gr1Executed, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Graphic2
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "График 2";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(Gr2Executed, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Graphic3
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "График 3";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(Gr3Executed, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Options
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Конфигурация";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            Command = new DelegateCommand(ConfigExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        public static ControlData Graphics
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "Графики";

                    if (!_dataCollection.ContainsKey(Str))
                    {
                        MenuItemData menuItemData = new MenuItemData()
                        {
                            Label = Str,
                            //SmallImage = new Uri("/RZD_maps;component/Images/NewDocument_16x16.png", UriKind.Relative),
                            //Command = new DelegateCommand(DefaultExecuted, DefaultCanExecute),
                        };
                        _dataCollection[Str] = menuItemData;
                    }

                    return _dataCollection[Str];
                }
            }
        }

        #endregion


        private static void DefaultExecuted()
        {
        }

        private static void BingExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.bing;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void OSMExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.osm;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void PlainExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.plain;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void VehicleExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.vehicle;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void StationExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.station;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void LineExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.line;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void MarkersExecuted()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.markers;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void Scale100Executed()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.scale100;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void Scale10Executed()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.scale10;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void LookRoadExecuted()
        {
        }

        private static void LookHybridExecuted()
        {
        }

        private static void Gr1Executed()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.gr1;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void Gr2Executed()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.gr2;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void Gr3Executed()
        {
            Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            evnt.command = Infrastructure.ControlDataCommandEnum.gr3;
            ViewModel.OnTransferControlData(evnt);
        }

        private static void ConfigExecuted()
        {
            RZD_maps.MapPath.Views.WindowMapPath vw = new MapPath.Views.WindowMapPath();
            vw.Show();
            
            //Infrastructure.RZD_mapsEvent evnt = new Infrastructure.RZD_mapsEvent();
            //evnt.command = Infrastructure.ControlDataCommandEnum.config;
            //ViewModel.OnTransferControlData(evnt);
        }

        private static bool DefaultCanExecute()
        {
            return true;
        }



        #region Data

        private static object _lockObject = new object();
        private static Dictionary<string, ControlData> _dataCollection = new Dictionary<string, ControlData>();

        // Store any data that doesnt inherit from ControlData
        private static Dictionary<string, object> _miscData = new Dictionary<string, object>();

        #endregion Data


    }

}
